<template>
  <el-card>
    <template #header>
      <div class="header">
        <div>分类销售排行</div>
        <el-button size="small" type="primary" class="bottom">商品</el-button>
        <el-button size="small" class="bottom">品类</el-button>
      </div>
    </template>
    <v-chart autoresize :option="setOption()" style="height: 400px"></v-chart>
  </el-card>
</template>

<script setup lang="ts">
// 导入计算属性
import { computed } from 'vue'
// 导入 仓库
import useEchartStore from '@/stores/echart'

// 获取仓库实例
const echartStore = useEchartStore()

// 拿取数据
// const saleRank = computed(() => {
let { category, goods } = echartStore.storeEchartData.saleRank

let { axisX, data1 } = category

let arrStr = axisX.map((item) => item)

let arrNum = data1.map((item) => item)
// return { arrNum, arrStr }
// })

const setOption = () => ({
  tooltip: {
    trigger: 'item'
  },
  legend: {
    top: '5%',
    left: 'center'
  },
  series: [
    {
      name: 'Access From',
      type: 'pie',
      radius: ['50%', '70%'],
      // avoidLabelOverlap: false,
      itemStyle: {
        borderRadius: 10,
        borderColor: '#fff',
        borderWidth: 2
      },
      label: {
        show: true
        // position: 'center'
      },
      // emphasis: {
      //   label: {
      //     show: true,
      //     fontSize: 20,
      //     fontWeight: 'bold'
      //   }
      // },
      labelLine: {
        show: true,
        length: 10,
        length2: 20
      },
      data: [
        { value: 1048, name: 'Search Engine' },
        { value: 735, name: 'Direct' },
        { value: 580, name: 'Email' },
        { value: 484, name: 'Union Ads' },
        { value: 300, name: 'Video Ads' }
      ]
    }
  ]
})
</script>

<style lang="scss" scoped>
.bottom {
  float: right;
}
.chart {
  height: 400px;
  width: 400px;
}
</style>
